﻿<%@ WebHandler Language="C#" Class="edituserAjax" %>

using System;
using System.Web;

public class edituserAjax : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string oper=context.Request.QueryString["oper"].ToString();//操作类型 1:判断密码是否相等，2：更新信息
        string username = context.Request.QueryString["user"].ToString();
        string pwd = context.Request.QueryString["pwd"].ToString();
        string ret = "";  //返回到js中的值。  0：输入的密码与旧密码不匹配。1：密码匹配。
        
        NVR.BLL.UserInfo user = new NVR.BLL.UserInfo();
        NVR.Entity.userInfo userInfo = new NVR.Entity.userInfo();
        userInfo = user.GetUserInfo(username);
        if(oper=="1") //判断用户密码是否一致
        {
            if (pwd != userInfo.pwd)
            {
                ret = "0";
            }
            else
            {
                ret = "1";
            }
        }
        if(oper=="2")
        {
            string tel = context.Request.QueryString["tel"].ToString();
            string qq = context.Request.QueryString["qq"].ToString();
            string email = context.Request.QueryString["email"].ToString();
            NVR.Entity.userInfo updateUser = new NVR.Entity.userInfo();
            updateUser.username = username;
            updateUser.parentid = userInfo.parentid;
            updateUser.purview = userInfo.purview;

            updateUser.regDate = DateTime.Now;
            updateUser.pwd = pwd;
            updateUser.tel = tel;
            updateUser.qq = qq;
            updateUser.email = email;
            if (user.UpdateUser(updateUser) == 1)
            {
                ret = "2";   //更新成功
            }
            else
            {
                ret = "3";  //更新失败
            } 
        }
        context.Response.Write(ret);
    }
    public bool IsReusable {
        get {
            return false;
        }
    }
}